package edu.hgnc.interceptor;

import edu.hgnc.controller.testController.Test03;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.web.servlet.AsyncHandlerInterceptor;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class HandlerMappingInterceptor implements HandlerInterceptor {

	private static Log logger = LogFactory.getLog(HandlerMappingInterceptor.class);

	/**
	 */
	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
		// return HandlerInterceptor.super.preHandle(request, response, handler);
		// 返回false不会执行目标方法
		logger.warn("是否执行拦截器"+true);
		return true;
	}

	/**
	 * @throws Exception in case of errors
	 */
	@Override
	public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
		logger.warn("===========================postHandle===========================");

	}

	/**
	 * @throws Exception in case of errors
	 */
	@Override
	public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
		logger.warn("===========================afterCompletion===========================");
	}
}
